package com.wisemoresystem.seal.action.seal.start;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.model.t_seal;
import com.wisemoresystem.seal.service.SealSetService;

/**
 * 印章启用
 * 
 * @author Administrator
 *
 */
@Controller("ixSealStart")
@Scope("prototype")
@RequestMapping("/ix/seal/set/start")
public class SealStartAction extends ProjBaseAction {

	@Autowired
	private SealSetService sealService;

	/**
	 * 印章启用列表
	 * 
	 * @param srh_name
	 * @return
	 */
	@RequestMapping("/list")
	public ModelAndView list(String srh_name) {

		List<Map<String, Object>> list = sealService.selectSealStartList(
				srh_name, page);

		ModelAndView mv = new ModelAndView("/jsp/seal/set/start/list");
		mv.addObject("list", list);
		return mv;
	}

	/**
	 * 启用操作
	 * 
	 * @param seal_id
	 *            印章id
	 * @param sta
	 *            状态
	 * @throws IOException
	 */
	@RequestMapping("/operate")
	public void operate(String seal_id, String sta) throws IOException {
		resp.setCharacterEncoding("utf-8");

		t_seal sealDb = oc.findObjById(seal_id, t_seal.class);
		sealDb.setFlag(sta);
		sealDb.setFlag_use("未领取");
		oc.updateObj(sealDb);

		logT.logH("印章启用", t_seal.class, sealDb.get_id());

		resp.getWriter().print("success");
		resp.getWriter().flush();
	}

}
